<template>
  <el-dialog title="风机控制" :visible.sync="visible" width="520px" append-to-body custom-class="fen_control">
    <el-form ref="form" :model="form" label-width="80px" label-position="left" size="small">
      <!-- <el-form-item label="开/关" prop="status">
        <el-switch v-model="form.status" />
      </el-form-item> -->
      <el-form-item label="运行状态">
        <el-radio-group v-model="form.runningStatus">
          <el-radio :label="1">运行</el-radio>
          <el-radio :label="0">关闭</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="运行模式">
        <el-radio-group v-model="form.operatingMode">
          <el-radio :label="1">手动</el-radio>
          <el-radio :label="2">自动</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="风机频率">
        <el-select v-model="form.frequency" placeholder="请选择风机频率" style="width: 100%;">
          <el-option label="10Hz" value="10" />
          <el-option label="30Hz" value="30" />
          <el-option label="50Hz" value="50" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="开启时间">
        <div>
          <el-radio-group v-model="form.resource">
            <el-radio label="常开" />
            <el-radio label="自定义" />
            <el-radio label="每天" />
          </el-radio-group>
        </div>
        <div>
          <el-time-picker
            v-model="value1"
            is-range
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            placeholder="选择时间范围"
          />
        </div>
      </el-form-item> -->
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" size="small" @click="submitForm">提交</el-button>
      <el-button size="small" @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getEqu } from '@/api/fjgs/equ'
import { singleControl } from '@/api/fjgs/fjMutipleControl.js'
export default {
  data() {
    return {
      visible: false,
      tabPosition: '',
      cruent: '',
      form: {},
      value1: []
    }
  },
  methods: {
    // open(options) {
    //   this.visible = true
    // },
    reset() {
      this.form = {
        confEquId: null,
        operatingMode: null,
        runningStatus: null,
        frequency: null
      }
    },
    open(row) {
      const id = row.id || this.ids
      this.reset()
      getEqu(id).then(response => {
        this.form = {
          confEquId: response.data.equOperation.confEquId,
          operatingMode: response.data.equOperation.operatingMode,
          runningStatus: response.data.equOperation.runningStatus,
          frequency: response.data.equOperation.frequency
        }
        this.visible = true
      })
    },
    handEdit(index, row) {
      this.cruent = index
    },
    cancel() {
      this.visible = false
    },
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          singleControl(this.form).then(response => {
            this.msgSuccess('修改成功')
            this.cancel()
            this.$emit('success')
            // this.getList()
          })
        }
      })
    }
  }
}
</script>

  <style lang="scss" >
  .fen_control {
      .el-dialog__body {
        padding: 16px 20px;
      }
      .el-form-item__label {
        padding-bottom: 0;
      }
  }

  </style>

